package com.suzhiliang.springbootlesson.loggerInterceptor;

import com.alibaba.fastjson.JSONObject;
import com.suzhiliang.springbootlesson.util.ContextUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * Copyright (C), 2015-2018, XXX有限公司
 *
 * @ClassName: LoggerInterceptorController
 * @Author: xmm
 * @Date: 2018/10/24 16:49
 * @Description: 控制器类，用来测试拦截器写日志信息
 * @Version 1.0
 */
@RestController
@RequestMapping(value = "loggerInterceptorController")
public class LoggerInterceptorController {

    @RequestMapping(value = "test")
    public JSONObject test(HttpServletRequest request,String name){
        JSONObject object = new JSONObject();
        object.put("returnMsg","用户"+name+"测试成功");
        request.setAttribute(ContextUtils.LOGGER_RETURN,object);
        return object;
    }
}
